Enable download of user credentials.

Closes #529.

Akinori MUSHA 10 years ago
parent
commit
b8a4c268ce

+ 3 - 1
app/controllers/user_credentials_controller.rb

@@ -8,7 +8,9 @@ class UserCredentialsController < ApplicationController
8 8
 
9 9
     respond_to do |format|
10 10
       format.html
11
-      format.json { render json: @user_credentials }
11
+      format.json {
12
+        send_data Utils.pretty_jsonify(@user_credentials.limit(nil).as_json), disposition: 'attachment'
13
+      }
12 14
     end
13 15
   end
14 16
 

+ 3 - 2
app/views/user_credentials/index.html.erb

@@ -37,8 +37,9 @@
37 37
       <br/>
38 38
 
39 39
       <div class="btn-group">
40
-        <%= link_to '<span class="glyphicon glyphicon-plus"></span> New Credential'.html_safe, new_user_credential_path, class: "btn btn-default" %>
40
+        <%= link_to new_user_credential_path, class: "btn btn-default" do %><span class="glyphicon glyphicon-plus"></span> New Credential<% end %>
41
+        <%= link_to user_credentials_path(format: :json), class: "btn btn-default" do %><span class="glyphicon glyphicon-download-alt"></span> Download Credentials<% end %>
41 42
       </div>
42 43
     </div>
43 44
   </div>
44
-</div>
45
+</div>